/**
 * 等待通用方法
 * @param ms 等待时间
 * @returns Promise
 */
export const timeout = (ms: number) => {
  return new Promise((resolve) => {
    setTimeout(resolve, ms, 'done')
  })
}


export const hasClass = (element:Element,className:string) => { 
  if (element.classList.contains(className)) return true
  return false
}

/**
 * 为 class 打补丁
 */
export function patchClass(el: Element, value: string | null) {
	if (value == null) {
		el.removeAttribute('class')
	} else {
		el.className = value
	}
}


// 回到顶部
export const scrollTop = () => {
  window.scrollTo({ top: 0, behavior: 'smooth' })
}